<template>
  <el-dialog
    title="新建企业"
    :visible.sync="dialogVisible"
    width="30%">
    <span>
      <ul>
        <li style="margin-bottom: 10px">
          <span>企业账号:</span>
          <input type="text" placeholder="(必填)" v-model="userCode">
        </li>
        <li>
          <span>企业名称:</span>
          <input type="text" placeholder="(必填)" v-model="companyName">
        </li>
        <li style="margin: 10px 0">
         <span>联系人:</span>
          <input type="text" placeholder="(必填)" v-model="contactPerson">
        </li>
        <li>
         <span>联系电话:</span>
          <input type="text" placeholder="(必填)用作企业登录账号" v-model="contactNumber">
        </li>
        <li style="width: 100%;margin-top: 10px">
          <span style="margin-left: 19%">{{tip}}</span>
        </li>
      </ul>
    </span>
    <span slot="footer" class="dialog-footer" style="display: flex;justify-content: center;align-items: center">
    <el-button @click="dialogVisible = false">取 消</el-button>
    <el-button type="primary" @click="sendAjax">确 定</el-button>
  </span>
  </el-dialog>
</template>

<script>
/*eslint-disable*/
import {addEnterprise} from '@/utils/enterpriselist';
  export default {
    name:"index",
    data() {
      return {
        dialogVisible: false,
        companyName:"",
        contactPerson:"",
        contactNumber:"",
        userCode:""
      };
    },
    props: {
      tip: {
        type: String,
        default: "注：密码初始统一为：123456"
      },
    },
    methods: {
      changeDisable(){
        this.dialogVisible=true
      },
      sendAjax(){
        let totalData={
          userCode:this.userCode,
          userName:this.companyName,
          contacts:this.contactPerson,
          phone:this.contactNumber
        };
        addEnterprise(totalData)
          .then(rawRes=> {
            return rawRes.data
          })
          .then(res=>{
            this.$emit('addData',res.CmUser)
          });
        this.dialogVisible = false
      }
    },

  };
</script>

<style scoped>
  ul{
    padding: 0;
  }
  li{
    list-style:none;
    display: flex;
    align-items: center;
    justify-content: space-between;
  }
  li>input{
    width: 80%;
    font-size: 12px;
    color: #3c3c3c;
    height: 35px;
  }
</style>
